package com.itheima.coll;

import java.util.ArrayList;
import java.util.Collection;
import java.util.function.Predicate;

/*
Collection 常用的方法

 */
public class Demo01 {

    public static void main(String[] args) {
        //创建对象
        Collection<String>  list= new ArrayList<>();
        list.add("吴亦凡1");
        list.add("吴亦凡2");
        list.add("吴亦凡3");
        list.add("吴亦凡4");

        System.out.println(list);
        boolean flag = list.remove("吴亦凡1");
        System.out.println(flag);
        System.out.println(list);
        //list.clear();
      //  System.out.println(list);
       // System.out.println(list.isEmpty());

        System.out.println(list.contains("吴亦凡1"));
        System.out.println(list.contains("吴亦凡2"));

        System.out.println(list.size());


        list.removeIf(new Predicate<String>() {
            @Override
            public boolean test(String s) {
                return s.startsWith("吴亦凡");
            }
        });
        list.removeIf(s -> s.startsWith("吴亦凡"));
        System.out.println(list);
    }


}
